<?php
$this->title="phpinfo";
?>
<?php
phpinfo();

$php_ini_contents = php_ini_get_contents();
$output = str_replace("\n", "\n<br/>", $php_ini_contents);
echo  '----------------------' . "<br/>\n";
echo 'php.ini' . "<br/>\n";
echo  '----------------------' . "<br/>\n";
echo $output;

$phpfpm_conf_contents = phpfpm_conf_get_contents();
$output = str_replace("\n", "\n<br/>", $phpfpm_conf_contents);
echo  '----------------------' . "<br/>\n";
echo 'php-fpm.conf' . "<br/>\n";
echo  '----------------------' . "<br/>\n";
echo $output;

function php_ini_get_contents()
{
    //获取php.ini路径
    $php_ini_file = php_ini_loaded_file();
    $result = file_get_contents($php_ini_file);
    return $result;
}

function phpfpm_conf_get_contents()
{
    //获取php.ini路径
    $php_ini_file = php_ini_loaded_file();
    $phpfpm_conf_file = dirname($php_ini_file) . '/php-fpm.conf';
    if (file_exists($phpfpm_conf_file))
    {
        $result = file_get_contents($phpfpm_conf_file);
    }
    else
    {
        $result = '';
    }
    return $result;
}

//执行一个系统命令$command并返回系统提示信息
function execute($command)
{
    $result = FALSE;
    if (is_string($command))
    {
        ob_start();
        passthru($command);
        $result = ob_get_contents();
        ob_end_clean();
        $result = htmlspecialchars($result);
    }
    return $result;
}
